package com.match;

import com.match.entry.Mail;
import com.match.entry.MailAttach;
import com.match.util.SendMailUtil;

import java.util.ArrayList;
import java.util.List;

public class SendMailDemo {

    public static void main(String[] args) {
        Mail mail = new Mail();
        mail.setUserName("xxxxxxxxx@aliyun.com");//用户名
        mail.setPassword("xxxxxx");//授权码或密码
        mail.setHost("smtp.aliyun.com");
        mail.setProtocol("smtp");
        mail.setAuth(true);
        mail.setSocketFactory("javax.net.ssl.SSLSocketFactory");
        mail.setPort(465);
        mail.setFromEmail("xxxxxxxxx@aliyun.com");//发送者
        mail.setRecipient("xxxxxxxx@qq.com");//接收者
        mail.setSubject("带附件和带图片的的邮件");

        List<MailAttach> list = new ArrayList<>();
        List<MailAttach> list1 = new ArrayList<>();
        MailAttach attach1 = new MailAttach();
        attach1.setContent("收到请回复，谢谢<br/>");
        attach1.setFileName("1.jpg");
        attach1.setPic(true);
        MailAttach attach2 = new MailAttach();
        attach2.setFileName("1.zip");
        list.add(attach1);
        list.add(attach2);
        list1.add(attach1);
        mail.setMailAttachList(list);
        mail.setMailContentList(list1);
        SendMailUtil.sendMail(mail);
    }
}

